package www.geek.filemanager.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import www.geek.filemanager.R;


/**
 * TODO		: 主页的4个按钮适配器
 *
 * @author : zhanggeng
 * @version : v1.0
 *          ----------修订历史-----------
 * @date : 2015-7-24
 */
public class HomeGridViewAdapter extends BaseAdapter {

    private Context context = null;

    private LayoutInflater inflater = null;


    private Integer[] img_array = {R.drawable.resource_management , R.drawable.application_management ,
            R.drawable.cloud_backup ,R.drawable.usercenter};

    public HomeGridViewAdapter(Context context){

        context = context;
        inflater = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
    }

    @Override
    public int getCount() {
        return img_array.length;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder ;

        if(null == convertView){
            convertView = inflater.inflate(R.layout.item_homepage_gridview, null);
            holder = new ViewHolder();
            holder.image = (ImageView) convertView.findViewById(R.id.item_gridview);
            convertView.setTag(holder);
        }else{
            holder = (ViewHolder) convertView.getTag();
        }

        holder.image.setBackgroundResource(img_array[position]);



        return convertView;
    }

    class ViewHolder{
        ImageView image;
    }
}
